<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeTint - Source code highlighting in javascript</title>

<script type="text/javascript" src="../BLite/BLite.js"></script>
<script type="text/javascript" src="./CodeTint.js"></script>

<link type="text/css" rel="stylesheet" href="./CodeTintWhite.css" />

</head>

<body>

<h1>CodeTint</h1>

<p>CodeTint is modular javascript source code highlighter that uses finite-state-machine concept rather than regular expressions. To highlight source code in your web page, you need to download <a href="http://code.google.com/p/blite">BLite library</a> and <a href="http://code.google.com/p/codetint/">CodeTint</a> package. To start syntax highlighting process add this script to your page:</p>

<pre class="lang-js">
BLite.ready(function() { CodeTint.addAll().process(); });
</pre>

<p>After calling this script all &lt;pre&gt; and &lt;code&gt; elements will be matched and processed. If you want to process some element, you must include &quot;lang&quot; class that describes how module to use to process content inside that container. Currently implemented languages are:</p>

<ul>
 <li><b>&quot;lang-c&quot;</b> - C/C++ language module.</li>
 <li><b>&quot;lang-cmake&quot;</b> - CMake script module.</li>
 <li><b>&quot;lang-html&quot;</b> - Html module (TODO).</li>
 <li><b>&quot;lang-js&quot;</b> - JavaScript language module.</li>
 <li><b>&quot;lang-shell&quot;</b> - Shell module (TODO).</li>
 <li><b>&quot;lang-xml&quot;</b> - Xml module (TODO).</li>
</ul>

<p>For example if you want to process some of your &lt;pre&gt; tag by C/C++ language module, declare it as &lt;pre class=&quot;lang-c&quot;&gt;content&lt;/pre&gt;.</p>

<h2>C/C++ Language module</h2>

<pre class="lang-c">
// C/C++ Syntax Highlighting test.
//
// Preprocessor, comments, strings, keywords and much more.

// Preprocessor 
#include &lt;stdio.h&gt;

#if defined(USE_MY_FILE)
#include &quot;myfile.h&quot;
#endif // USE_MY_FILE

// Keywords - namespaces.
using namespace MyApp;

// Keywords - declaring structure, see how capitalization works.
struct Point
{
  int x;
  int y;
};

/**
 * This is application entry point, also multiline comment test.
 */
void main(int argc, char* argv[])
{
  // String escaping.
  printf(&quot;I'm \&quot;C/C++\&quot; Syntax Highlighter\n&quot;);

  // Keywords.
  int a = 10;
  float b = 20.4;
  char c = '\'';

  // Capitalization.
  Point pt;

  printf(&quot;%d, %g %c\n&quot;, a, b, c);

  return 0;
}
</pre>

<h2>Cmake Module</h2>

<pre class="lang-cmake">
# CMake Module.
#
# There is nothing very special. We treat cmake scripts as normal scripts,
# symbols, comments and some other tokens are highlighted.

# Reguire minimum version of CMake
CMake_Minimum_Required(VERSION 2.6)

# Project Declaration.
Project(MyProj C CXX)

# Project Directory.
Set(MyProj_DIR "")

# Project sources.
Set(MyProj_SOURCES
  ${MyProj_DIR}/main.cpp
)

Set(MyProj_HEADERS
  ${MyProj_DIR}/main.h
)

Include_Directories(${MyProj_DIR})

# Pthread library is we are in POSIX.
If(NOT WIN32)
  Link_Libraries(pthread)
EndIf(NOT WIN32)

# Debug mode.
If(${CMAKE_BUILD_TYPE} MATCHES "Debug")
  Add_Definitions(-D_DEBUG)
EndIf(${CMAKE_BUILD_TYPE} MATCHES "Debug")

# Some other stuff.
Add_Library(MyLib SHARED ${MyProj_SOURCES} ${MyProj_HEADERS})
Install(TARGETS MyLib LIBRARY DESTINATION lib)

ForEach(i ${MyProj_HEADERS})
  Get_Filename_Component(file ${i} NAME)
  Install(FILES ${i} DESTINATION "include/MyProj")
EndForEach(i)
</pre>

<script type="text/javascript">
BLite.Dom.ready(function() { CodeTint.addAll().process(); });
</script>

</body>
</html>
